package com.vision.frame.Bean;


import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ResultObject {

    private int pageSize;
    private int pageNumber;
    private int total;
    private List<?> rows;
    private Map<String, Object> maprow;
    private String msg;
    private String detailMsg;
    private Object objOther;
    private static int iTotal = 0;
    private static String tmpSQL = "";

    public Object getObjOther() {
        return this.objOther;
    }

    public void setObjOther(Object objOther) {
        this.objOther = objOther;
    }

    public ResultObject() {
    }



    public void onSetErrorMsg(Exception e) {
        if (e instanceof Exception) {
            String msg = e.getMessage();
            if (StringUtils.isBlank(msg)) {
                msg = e.getCause().getLocalizedMessage();
            }

            if (StringUtils.isBlank(msg)) {
                msg = ((Exception)e.getCause()).getMessage();
            }

            this.setMsg(msg);
        } else if (StringUtils.isBlank(e.getLocalizedMessage())) {
            this.setMsg("未知错误！\n" + Arrays.toString(e.getStackTrace()));
        } else {
            this.setMsg(e.getLocalizedMessage());
        }

        throw new RuntimeException(this.getMsg());
    }

    public Map<String, Object> getMaprow() {
        return this.maprow;
    }

    public void setMaprow(Map<String, Object> maprow) {
        this.maprow = maprow;
    }

    public int getPageSize() {
        return this.pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPageNumber() {
        return this.pageNumber;
    }

    public void setPageNumber(int pageNumber) {
        this.pageNumber = pageNumber;
    }

    public int getTotal() {
        return this.total;
    }

    public void setTotal(int totalCount) {
        this.total = totalCount;
    }

    public List<?> getRows() {
        return this.rows;
    }

    public void setRows(List<?> rows) {
        this.rows = rows;
    }

    public String getMsg() {
        return this.msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getDetailMsg() {
        return this.detailMsg;
    }

    public void setDetailMsg(String detailMsg) {
        this.detailMsg = detailMsg;
    }
}

